package com.example.controller;

import com.example.model.Task;
import com.example.service.TaskService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/task")
public class TaskController {
    private final TaskService taskService;
    public TaskController(TaskService taskService){
        this.taskService=taskService;
    }
    @PostMapping("/add")
    public void add(@RequestBody Task task){
        taskService.addToTask(task);
    }
    @PostMapping("/update")
    public void update(@RequestBody Task task){
        taskService.updateTheTask(task);
    }
    @GetMapping("/delete")
    public void delete(@RequestParam(value = "taskId")String taskId){
        taskService.deleteFromTask(taskId);
    }
    @GetMapping("/select")
    public List<Task> select(@RequestParam(value = "courseId")String courseId){
        return taskService.selectFromTask(courseId);
    }
    @GetMapping("/status")
    public void status(@RequestParam(value = "taskId") String taskId){
        taskService.statusChange(taskId);
    }
    @PostMapping("/mark")
    public void mark(@RequestParam(value = "filedId")int fileId,@RequestParam(value = "core")String core){
        taskService.mark(fileId,core);
    }
}
